<template>
  <div class="app-container">
    <div class="filter-container default-box">
      <span style="padding-left: 100px;">用户ID：</span>
      <el-input v-model="listQuery.title" placeholder="请输入用户ID" style="width: 240px;" class="filter-item" />
      <span style="padding-left: 100px;">账号：</span>
      <el-input v-model="listQuery.title" placeholder="请输入账号" style="width: 240px;" class="filter-item" />
      <span style="padding-left: 100px;">广告包：</span>
      <el-select v-model="statusvalue" filterable placeholder="请选择">
        <el-option v-for="item in statusoptions" :key="item.value" :label="item.label" :value="item.value" />
      </el-select>
      <span style="padding-left: 100px;">挂单状态：</span>
      <el-select v-model="statusvalue" filterable placeholder="请选择">
        <el-option v-for="item in statusoptions" :key="item.value" :label="item.label" :value="item.value" />
      </el-select>
      <el-button class="filter-item" type="primary" icon="el-icon-search" style="margin-left:50px" round>
        查询
      </el-button>
      <el-button class="filter-item" icon="el-icon-refresh-right" round>
        重置
      </el-button>
    </div>
    <div class="default-box">
      <el-table
        :key="tableKey"
        v-loading="listLoading"
        :data="list"
        fit
        highlight-current-row
        style="width: 100%;"
      >
        <el-table-column label="账号" min-width="200" show-overflow-tooltip>
          <template>
            <span>18324729452</span>
          </template>
        </el-table-column>
        <el-table-column label="广告包" width="150">
          <template>
            <span>家庭旅行包</span>
          </template>
        </el-table-column>
        <el-table-column label="类型" width="150">
          <template>
            <el-button type="text">求购</el-button>
          </template>
        </el-table-column>
        <el-table-column label="单价" width="150">
          <template>
            <span>30</span>
          </template>
        </el-table-column>
        <el-table-column label="挂单数量" width="150">
          <template>
            <span>30</span>
          </template>
        </el-table-column>
        <el-table-column label="完成数量" width="150">
          <template>
            <span>30</span>
          </template>
        </el-table-column>
        <el-table-column label="图片" width="150">
          <template>
            <el-image
              style="width: 38px; height: 38px"
              :src="srcurl"
              :preview-src-list="srcList"
            />
          </template>
        </el-table-column>
        <el-table-column label="状态" width="150">
          <template>
            <el-button type="text">已关闭</el-button>
          </template>
        </el-table-column>
        <el-table-column label="挂单时间" width="200">
          <template>
            <span>2023-03-04 14:44:52</span>
          </template>
        </el-table-column>
        <el-table-column label="完成时间" width="200">
          <template>
            <span>2023-03-04 14:44:52</span>
          </template>
        </el-table-column>
        <el-table-column label="查看日志" width="150">
          <template>
            <span :style="{borderBottom:'1px solid '+$store.state.settings.theme,color:$store.state.settings.theme}">点击查看</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="200" class-name="small-padding fixed-width">
          <template>
            <el-button type="warning" round>
              关闭交易
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" />
    </div>
  </div>
</template>

<script>
import { fetchList } from '@/api/article'
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
export default {
  name: 'Adminrole',
  components: { Pagination },
  data() {
    return {
      tableKey: 0,
      list: null,
      total: 0,
      listLoading: true,
      listQuery: {
        page: 1,
        limit: 10,
        importance: undefined,
        title: undefined,
        type: undefined,
        sort: '+id'
      },
      statusoptions: [{ // 状态选择项组
        value: '',
        label: '全部'
      }, {
        value: '未完成',
        label: '未完成'
      }, {
        value: '认证通过',
        label: '认证通过'
      }],
      statusvalue: '', // 状态的类型
      value1: false,
      srcurl: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg',
      srcList: [
        'https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg',
        'https://fuss10.elemecdn.com/1/8e/aeffeb4de74e2fde4bd74fc7b4486jpeg.jpeg'
      ]
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      this.listLoading = true
      fetchList(this.listQuery).then(response => {
        this.list = response.data.items
        this.total = response.data.total
        setTimeout(() => {
          this.listLoading = false
        }, 1.5 * 1000)
      })
    }
  }
}
</script>
<style scoped>
  [class^=el-icon-], [class*=" el-icon-"]{
    font-size: 16px;
  }
  .small-padding i{
    margin-right: 12px;
  }
  .small-padding i:last-child{
    margin-right: 0px;
  }
  ::v-deep .filter-container .el-input--medium .el-input__inner{
    width: 240px;
  }
</style>
